<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        window.onload = function () {
            //得到画笔
            var bi = document.querySelector('canvas').getContext('2d');
            bi.beginPath();
            bi.moveTo(560, 124);
            bi.lineTo(241, 178);
            bi.lineTo(450, 570);
            bi.lineTo(80, 534);
            bi.lineTo(346, 334);
            bi.closePath();
            //填充颜色
            bi.fillStyle = 'cornflowerblue';
            bi.fill();
            //画线
            bi.stroke();
        }
    </script>
</head>

<body>
    <canvas width="600" height="600"></canvas>
</body>

</html>